import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, { Component } from 'react';
import * as T from '../types';
import './gift-status-tab.less';
import actions from '../actions/index';
import { connect } from 'react-redux';
import { store2Props } from '../selectors';
type IStatusTabProps = T.IProps & T.IStatusTabProps;
const typeList = [
  { value: 0, text: '已购买' },
  { value: 1, text: '已失效' },
];
@connect<Partial<IStatusTabProps>, T.ICouponStatusTabState>(store2Props, actions)
export default class GiftStatusTab extends Component<Partial<IStatusTabProps>, T.ICouponStatusTabState> {
  static options = {
    addGlobalClass: true,
  };
  constructor(props: IStatusTabProps) {
    super(props);
  }

  render() {
    let {
      actions: {
        action: { changeGiftStatus },
      },
      main: { giftStatusTab },
    } = this.props;
    console.log('giftStatusTab', giftStatusTab);
    return (
      <View className="giftStatusTab">
        {typeList.map((item, index) => {
          return (
            <View
              key={index}
              className={item.value == giftStatusTab ? 'tab-text curr' : 'tab-text'}
              onClick={() => {
                changeGiftStatus(item.value);
              }}
            >
              {item.text}
            </View>
          );
        })}
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
